#ifndef EGG_SCENE_H
#define EGG_SCENE_H

#include "RootActor.h"
#include "MeshActor.h"
#include "LightActor.h"
#include "CameraActor.h"
#include "TransformActor.h"
#include "BoundingDirtyCache.h"
#include "TransformDirtyCache.h"

namespace egg{

    class Scene{
    public:
        Scene();
        void runFrame();
        void addLight(Light* _light);
        void addCamera(Camera* _camera);
        void addFrameEndListener(Actor* _actor);
        void addFrameBeginListener(Actor* _actor);
        void addBoundingUpdateListener(Actor* _actor);
        void addTransformUpdateListener(Actor* _actor);

        inline Actor* getRoot(){
            return mRootActor;
        }
        inline const FrameEvent& getFrameEvent(){
            return mFrameEvent;
        }
    protected:
        virtual void update();
        virtual void render();
        virtual void sortCameras();
        virtual void visibleCull(Camera* _camera);
    protected:
        Actor* mRootActor;
        uint32 mMaxViewWidth;
        uint32 mMaxViewHeight;
        RendererPtr mRenderer;
        FrameEvent mFrameEvent;
        BoundingDirtyCache mBoundingDirtyCache;
        TransformDirtyCache mTransformDirtyCache;
        list<Camera*> mOrderedCameras;
        vector<Light*> mLights;
        vector<Camera*> mCameras;
        vector<Actor*> mFrameEndListeners;
        vector<Actor*> mFrameBeginListeners;
    };

}

#endif